package com.hospital.ssm.controller;

import com.hospital.ssm.dto.UserDto;
import com.hospital.ssm.model.DoctorType;
import com.hospital.ssm.model.ResultInfo;
import com.hospital.ssm.service.DoctorQualService;
import com.hospital.ssm.vo.DoctorQualAndType;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
public class DoctorQualController {

    @Autowired
    private DoctorQualService doctorQualService;

    @RequestMapping("/DoctorTypeUi")
    public String getAll(Integer dtId,Model model){
        try {
            List<DoctorQualAndType> all = doctorQualService.getAll(dtId);
            model.addAttribute("doctorType",all);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "/DoctorType";
    }

    @RequestMapping("/DoctorTypeadd")
    public String add(Integer dtDept,String createMan,String updateMan,Integer dtStatus){

        /*Date reDate = new Date(System.currentTimeMillis());
        String ft = new SimpleDateFormat("yyyy-MM-dd").format(reDate);
        model.addAttribute("loadtime", ft);*/
        System.out.println(dtDept);
//        try {
//            doctorQualService.insert(new DoctorType(dtDept,createTime,createMan,updateTime,updateMan,dtStatus));
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        return "redirect:DoctorTypeUi";
        return  null;
    }
    @PutMapping("/DoctorTypeupdate")
    public String update(Integer id, Integer dtDept, Date createTime, String createMan, Date updateTime, String updateMan, Integer dtStatus){

       /* Date reDate = new Date(System.currentTimeMillis());
        String ft = new SimpleDateFormat("yyyy-MM-dd").format(reDate);
        model.addAttribute("loadtime", ft);*/
        System.out.println(id);
        System.out.println(dtDept);
        try {
            doctorQualService.update(new DoctorType(id,dtDept,createTime,createMan,updateTime,updateMan,dtStatus));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "redirect:DoctorTypeUi";
    }






}
